#ifndef TABLEPRINTSETTINGS_H
#define TABLEPRINTSETTINGS_H

#include <QDialog>
#include<QtWidgets>

class tablePrintWidget;
namespace Ui {
class tablePrintSettings;
}


class tablePrintSettings : public QDialog
{
    Q_OBJECT

public:
    explicit tablePrintSettings(tablePrintWidget *parent);
    ~tablePrintSettings();

    void check(QString key);
signals:
    void signal_checked(QStringList orders, QString table, QString key, bool checked);
public slots:
    void tocheck(bool checked);

    void updatePixmap(QPixmap pixmap);
public:
    void recordMap(const QString &table, const QString &key, QObject *widget);

private slots:
    void on_pushButton_clicked();

    void on_pushButton_default_clicked();

private:

    template<typename T>
    class PairList : public QList<QPair<QString, T> >{
    public:
        bool contains(QString key) {
            for(int k = 0; k < this->count(); k ++) {
                if(this->at(k).first == key)
                    return true;
            }
            return false;
        }
        T value(const QString &key) {
            for(int k = 0; k < this->count(); k ++) {
                if(this->at(k).first == key)
                    return this->at(k).second;
            }
            return 0;
        }
        QString key(T value){
            for(int k = 0; k < this->count(); k ++) {
                if(this->at(k).second == value)
                    return this->at(k).first;
            }
            return "";
        }
        void append(QString key, T value ) {
            this->insert(this->count(), QPair<QString ,T>(key, value));
        }
        QStringList keys(T value) {
            QStringList rlist;
            for(int k = 0; k < this->count(); k ++) {
                if(this->at(k).second == value)
                    rlist << this->at(k).first;
            }
            return rlist;
        }
    };
    typedef QPair<QString, QObject *> PairWidget;
    typedef QPair<QString, QString> PairString;
    typedef PairList<QObject *> PairWidgetList;
    typedef PairList<QString> PairStringList;
    Ui::tablePrintSettings *ui;
    PairWidgetList keyWidgetList;
    PairStringList keyTableList;

    tablePrintWidget *backEngine;
};

#endif // TABLEPRINTSETTINGS_H
